// pages/newhome/newhome.js
// pages/home/
const api = require("../request/api")
const request = require("../request/request")
const util = require("../utils/util")
const App = getApp();

Page({


    /**
     * 页面的初始数据
     */
    data: {
        uid: 9,
        page: 1,
        page_size: 15,
        shop_list: [],

    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {

        this.get_shop_list()

    },

    go_search() {
        wx.navigateTo({
            url: '/pages/good/search',
        })
    },

    go_shop() {
        let url = '/pages/shop/shop'
        wx.navigateTo({
            url
        })
    },

    go_groupbuy() {
        wx.navigateTo({
            url: "plugin://groupbuy/home?pub_id=139549&sid=wx21d586e8db2ec146"

        })
    },

    go_hotel() {
        wx.navigateTo({
            url: "plugin://hotel/index?pub_id=139549&sid=wx21d586e8db2ec146"
        })
    },

    go_movie() {
        wx.navigateTo({
            url: "plugin-private://wx89752980e795bfde/pages/index/index?pub_id=139549&sid=wx21d586e8db2ec146"
        })
    },

    go_locallife() {
        wx.navigateTo({
            url: "plugin://locallife/index?pub_id=139549&sid=wx21d586e8db2ec146"
        })
    },

    go_ticket() {
        wx.navigateTo({
            url: "plugin://ticket/home?pub_id=139549&sid=wx21d586e8db2ec146"
        })
    },

    go_settling() {
        wx.navigateTo({
            url: '/pages/shop/settling',
        })
    },

    go_onlineshop() {
        wx.switchTab({
            url: "/pages/onlineshop/onlineshop"
        })
    },

    go_signin() {
        wx.navigateTo({
            url: "/pages/signin/signin",
        })
    },

    go_getticket() {
        wx.navigateTo({
            url: "/pages/ticket/newticket",
        })
    },

    get_shop_list() {
        let params = {
            page: this.data.page,
            pageSize: 3,
            uid: this.data.uid
        }
        request.post(api.shoplist, params).then(res => {
            this.setData({
                shop_list: res
            })
        })
    },

    go_shop_detail(e) {
        let id = e.currentTarget.dataset.id
        if (!id) {
            id = 32
        }
        wx.navigateTo({
            url: '/pages/shop/detail?id=' + id,
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})